package chapter4;
import java.util.Scanner;
/****************************************************************
 * Author：icynlau
 * Description: 显示一个月中的天数
 * Date:2021/4/2
 * ***************************************************************
 */
public class exc4_17 {
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		System.out.print("Enter a year:");
		int year=input.nextInt();
		System.out.print("Enter a month: ");
		String month=input.next();
		String[] arr= {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
		boolean isMonth=false;
		int nMonth=0;
		for(int i=0;i<12;i++) {
			if(month.equals(arr[i])) {
				isMonth=true;
				nMonth=i;
				break;
			}
		}
		if(!isMonth) {
			System.out.println(month+" is an invalid month name.");
		}
		
		int[] daysArr= {31,28,31,30,31,30,31,31,30,31,30,31};
		if(year%4==0&&year%100!=0||year%400==0) {
//			System.out.println("It's 闰年");
			daysArr[1]=29;
		}
		
		System.out.printf("%s %d has %d days.", month, year,daysArr[nMonth]);
		
		
	}

}
